﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data;

namespace BT_web__nhom06.VanPhongDoan
{
    public partial class Thongtin_CD : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string machidoan = Request.QueryString["id"];
            if (machidoan == null)
                Response.Redirect("QL_ChiDoan.aspx");

            //nếu không rỗng thì chạy

            if (!IsPostBack)
            {
                DataTable tbl = Tienichsql.ketnoicsdl.ChayLenhSelectDuLieu("SELECT * FROM chidoan where machidoan=@machidoan", "@machidoan", machidoan);
                if (tbl.Rows.Count > 0)
                {
                    DataRow dr = tbl.Rows[0];
                    lbmachidoan.Text = (string)dr["machidoan"];
                    lbtenchidoan.Text = dr["tenchidoan"].ToString();
                    DataTable tblbt = Tienichsql.ketnoicsdl.ChayLenhSelectDuLieu("Select ho, ten from doanvien, chidoan where doanvien.masinhvien = chidoan.masvbithuchidoan and chidoan.machidoan = @machidoan", "@machidoan", machidoan);
                    if (tblbt.Rows.Count > 0)
                    {
                        DataRow drbt = tblbt.Rows[0];
                        lbbithuchidoan.Text = (string)drbt["ho"] + " " + (string)drbt["ten"];
                    }
                    DataTable tblpbt = Tienichsql.ketnoicsdl.ChayLenhSelectDuLieu("Select ho, ten from doanvien, chidoan where doanvien.masinhvien = chidoan.masvphobithuchidoan and chidoan.machidoan = @machidoan", "@machidoan", machidoan);
                    if (tblbt.Rows.Count > 0)
                    {
                        DataRow drpbt = tblbt.Rows[0];
                        lbphobithuchidoan.Text = (string)drpbt["ho"] + " " + (string)drpbt["ten"];
                    }
                    else
                    {
                        lbphobithuchidoan.Text = "";
                    }
                    if (dr["dacdiem"].ToString() == "")
                    {
                        TextBox1.Text = "";
                    }
                    else
                        TextBox1.Text = (string)dr["dacdiem"];
                }
            }
        }

        protected void btnbangphancongnhiemvu_Click(object sender, EventArgs e)
        {
            Response.Redirect("QL_ChiDoan.aspx");
        }
    }
}